import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export let useEdit = defineStore('showEdit', () => {

    let show_edit = ref(false);  //是否展示

    let open_change = ref(1); //按需监控。

   

    let cur_subproject_id = ref("0");

    let cur_month = ref("1"); //1-12

    let cur_week_index = ref(0);


    let data_arr = ref([]); //编辑页面 过度数据

    let subproject_id_getter = computed(() => cur_subproject_id.value);
    let cur_month_getter = computed(() => cur_month.value);

    let show_edit_getter = computed(() => show_edit.value);

    let open_change_getter = computed(() => open_change.value);

    let data_arr_getter = computed(() => data_arr.value);

    function show_edit_fn(status) {
        show_edit.value = status   //必须使用.value
    };

    function cur_subproject_id_fn(status) {
        cur_subproject_id.value = status   //必须使用.value
    }

    function cur_month_fn(data) {
        cur_month.value = data   //必须使用.value
    }


    function open_change_fn() {
        open_change.value = Math.random();
    }



    function page_list_fn(data) {
        data_arr.value = data;
        console.log("data_arr.value--pinia", data_arr.value);
    }


    let obj = ref([]);//携带组件默认数据

    let obj_getter = computed(() => obj.value);

    function obj_fn(datas) {
        obj.value = datas;
    }


    /*--fix-bug-*/
    let cancle_change=ref(1);

    let cancle_change_getter = computed(() => cancle_change.value);

    function cancle_change_fn(datass){
        cancle_change.value=datass
    }







    return {
        cancle_change_getter,

        cancle_change_fn,
        
        obj_getter,
        obj_fn,

        subproject_id_getter,
        cur_month_getter,
        show_edit_getter,
        show_edit_fn,
        cur_subproject_id_fn,
        cur_month_fn,
        open_change_fn,
        open_change_getter,

        data_arr_getter,
        page_list_fn

    }

});
